From af277a631b2c0f47c030cf6f8017ba70cb814a20 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Thu, 22 Apr 2010 09:41:36 +0100 Subject: [PATCH] HAP 1GB: Add corner case handling for 1GB super page. - Without the check, guest memory allocation will never reach the boundary of a 1GB super page. Signed-off-by: Dongxiao Xu --- tools/libxc/xc_hvm_build.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/libxc/xc_hvm_build.c b/tools/libxc/xc_hvm_build.c index f774978977..47486907be 100644 --- a/tools/libxc/xc_hvm_build.c +++ b/tools/libxc/xc_hvm_build.c @@ -203,6 +203,14 @@ static int setup_guest(int xc_handle, if ( count > max_pages ) count = max_pages; + /* Take care the corner cases of super page tails */ + if ( ((cur_pages & (SUPERPAGE_1GB_NR_PFNS-1)) != 0) && + (count > (-cur_pages & (SUPERPAGE_1GB_NR_PFNS-1))) ) + count = -cur_pages & (SUPERPAGE_1GB_NR_PFNS-1); + else if ( ((count & (SUPERPAGE_1GB_NR_PFNS-1)) != 0) && + (count > SUPERPAGE_1GB_NR_PFNS) ) + count &= ~(SUPERPAGE_1GB_NR_PFNS - 1); + /* Attemp to allocate 1GB super page. Because in each pass we only * allocate at most 1GB, we don't have to clip super page boundaries. */ -- 2.30.2